<?php

/**
* GuideListFormModule.class.php
*
* Concrete page module responsable for creating slide show list
*
* @author     Blazej Zieba <b@zieba.info>
* @copyright  2007 konekto.com
* @version    CVS: $Id:$
*/

require_once("framework/PageModule.class.php");
require_once("MDB2.php");
require_once("HTML/QuickForm.php");
require_once("HTML/QuickForm/Renderer/Default.php");


// {{{ SlideShowListModule

class GuideListFormModule extends PageModule 
{
    // {{{ Class operations 

    // {{{ SlideShowListModule
    /**
    * C'tor
    */
    
    function GuideListFormModule()
    {
        trigger_error("ENTER GuideListFormModule::GuideListFormModule()", E_USER_NOTICE);
    }
    // }}}
    // {{{ getContent

    /**
    * Function returns page content
    *
    */

    function getContent()
    {

        trigger_error("ENTER GuideListFormModule::getContent()", E_USER_NOTICE);
        $options = &PEAR::getStaticProperty('CONFIG_INI','TEMPLATES'); 
 
        $tpl = new HTML_Template_IT($options["templates_dir"]);
        $tpl->loadTemplatefile("guide_list.tpl.xhtml",true,true);
        
        $options = &PEAR::getStaticProperty('CONFIG_INI','DSN'); 
        $dbh = new PDO($options['dsn_string']);
        $dbh->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
        $sth = $dbh->prepare("SELECT rowid,name FROM guide");
        $sth->execute();
        $options = &PEAR::getStaticProperty('CONFIG_INI','GLOBAL');
        while ( $row = $sth->fetch(PDO::FETCH_ASSOC) )
        {
            $tpl->setVariable("NAME",$row['name']);
            $tpl->setVariable("LINK",$options['service_url']."?cmd=ShowRoute&id=".$row['rowid']);
            $tpl->parse("row") ;
        }
        
        return $tpl->get();
    }
    
    // }}}

    // }}}
}

// }}} 

?>
